package org.neuedu.chapter04_0615;

public class MyDemo01 {
    public static void main(String[] args) {
        // 1.求和
        int arr[] = {5, 681, 3, 5, 7, 98, 9};
        double sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum = sum + arr[i];
        }
        System.out.println(sum);
        // 2.求平均值
        System.out.println(sum/arr.length);
        // 3.求偶数和
        sum = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 == 0) {
                sum = sum + arr[i];
            }
        }
        System.out.println(sum);
        // 4.求最大值和它的下标
        int max = arr[0];
        int index = 0;
        for (int i = 0; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
                index = i;
            }
        }
        System.out.println(index+","+max);
    }
}
